//基金信息
import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'manFundInfoM',
  state: {},
  effects: {
    //查询列表
    *getDataList({ payload, callback }, { call, put }) {
      const response = yield call(api.manFundInfo.tableList, payload);
      if (response?.code == '0') {
        callback(response?.data || {});
      } else {
        message.error(response?.msg || '查询表格失败！');
      }
    },
    //查询详情接口
    *getDetail({ payload, callback }, { call, put }) {
      const response = yield call(api.manFundInfo.getDetail, payload);
      if (response?.code == '0') {
        callback(response?.data?.dataSource || null);
      } else {
        message.error(response?.msg || '查询详情接口失败！');
        return;
      }
    },
    //新增编辑保存操作
    *saveData({ payload, callback }, { call, put }) {
      const response = yield call(api.manFundInfo.saveData, payload);
      if (response?.code == '0') {
        callback(true);
        message.success(response?.msg || '操作成功！');
      } else {
        message.error(response?.msg || '保存失败！');
        return;
      }
    },
    //批量确认
    *confirmData({ payload, callback }, { call, put }) {
      const response = yield call(api.manFundInfo.confimData, payload);
      if (response?.code == '0') {
        callback(true);
        message.success(response?.msg || '批量确认成功');
      } else {
        message.error(response?.msg || '批量确认失败！');
        return;
      }
    },
    //删除
    *deleteById({ payload, callback }, { call, put }) {
      const res = yield call(api.manFundInfo.deleteById, payload);
      if (res && res.code == 0) {
        callback(true);
      } else {
        message.error(res?.msg || '删除失败');
      }
    },
  },
  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
